<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc.">
        <meta name="author" content="Coderthemes">
        <!-- App Favicon icon -->
        <link rel="shortcut icon" href="assets/images/favicon.ico">
        <!-- App Title -->
        <title>{{config('app.name')}}</title>

        <link href="{{asset('sharecar/assets/css/bootstrap.min.css')}}" rel="stylesheet" type="text/css" />
        <link href="{{asset('sharecar/assets/css/core.css')}}" rel="stylesheet" type="text/css" />
        <link href="{{asset('sharecar/assets/css/components.css')}}" rel="stylesheet" type="text/css" />
        <link href="{{asset('sharecar/assets/css/icons.css')}}" rel="stylesheet" type="text/css" />
        <link href="{{asset('sharecar/assets/css/pages.css')}}" rel="stylesheet" type="text/css" />
        <link href="{{asset('sharecar/assets/css/menu.css')}}" rel="stylesheet" type="text/css" />
        <link href="{{asset('sharecar/assets/css/responsive.css')}}" rel="stylesheet" type="text/css" />

        <!-- HTML5 Shiv and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->

        <script src="{{asset('sharecar/assets/js/modernizr.min.js')}}"></script>

    </head>


    <body>


        @include('sharecar.header')


        <div class="wrapper">
            <div class="container">

                <!-- Page-Title -->
                

                <div class="row">
                    <div class="col-sm-12">
                        <div class="card-box">
                            <div class="row">
    @if(session('rs'))
    <div class="alert alert-{{session('rs')['status']}}">
    {{ session('rs')['msg'] }}
     </div>
    @endif
                                <div class="col-lg-8 col-sm-12">
                                    

                                   <div class="table-responsive">
                                        <table class="table m-0">

                                            <thead>
                                                <tr>
                                                    <th>Booking Time</th>
                                                    <th>Registration Number</th>
                                                    <th>Make/Model</th>
                                                    <th>Class</th>
                                                    <th>Price/Mins</th>
                                                    <th>Handler</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                              @foreach($list as $k=>$v)
                                          <tr>
                                            <td>{{$v->booking_at}}</td>
                                            <td>{{$v->car_code}}</th>
                                            <td>{{$v->car_model}}</td>
                                            <td>{{$v->car_type}}</td>
                                           
                                            <td>{{$v->car_price}}</td>
                                            <td>
                                        @if(empty($v->completed_at))
                                            @if(empty($v->picked_at))    
                                            <a class="btn btn-primary" href="{{url('order-pickup')}}?id={{$v->id}}">Pick up</a>
                                            <a class="btn btn-danger " href="{{url('order-cancel')}}?id={{$v->id}}">Cancel
                                              
                                            </a>
                                            @endif

                                            @if($v->picked_at)    
                                            <button class="btn btn-success btn-complete" data-id="{{$v->id}}" type="button">Return</button>
                                            @endif

                                        @else
                                        <a class="btn btn-purple" href="{{url('order-show')}}?id={{$v->id}}">Detial</a>
                                        @endif  
                                          </td>
                                          </tr>
                                              @endforeach  
                                            </tbody>
                                        </table>
                                    </div>

                                </div>

                                <div class="col-lg-4 col-sm-12">
                                   <div id="map" style="height: 500px;"></div>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>



                


                


                


                

            </div> <!-- end container -->
        </div>
        <!-- end wrapper -->


        <!-- jQuery  -->
        <script src="{{asset('sharecar/assets/js/jquery.min.js')}}"></script>
        <script src="{{asset('sharecar/assets/js/bootstrap.min.js')}}"></script>
        <script src="{{asset('sharecar/assets/js/detect.js')}}"></script>
        <script src="{{asset('sharecar/assets/js/fastclick.js')}}"></script>
        <script src="{{asset('sharecar/assets/js/jquery.slimscroll.js')}}"></script>
        <script src="{{asset('sharecar/assets/js/jquery.blockUI.js')}}"></script>
        <script src="{{asset('sharecar/assets/js/waves.js')}}"></script>
        <script src="{{asset('sharecar/assets/js/wow.min.js')}}"></script>
        <script src="{{asset('sharecar/assets/js/jquery.nicescroll.js')}}"></script>
        <script src="{{asset('sharecar/assets/js/jquery.scrollTo.min.js')}}"></script>

        <!-- App core js -->
        <script src="{{asset('sharecar/assets/js/jquery.core.js')}}"></script>
        <script src="{{asset('sharecar/assets/js/jquery.app.js')}}"></script>

        <script type="text/javascript">
            $('.btn-complete').on('click',function(){
                var id  = $(this).data('id');
                var url = "{{url('order-complete')}}?id="+id;
                if (navigator.geolocation) {          
                    navigator.geolocation.getCurrentPosition(function(position) {
                    var pos = {
                      lat: position.coords.latitude,
                      lng: position.coords.longitude
                    };
                    var data = {};
                    data.id = id;
                    data.lnglat = pos.lng+','+pos.lat;
                    $.get(url,data,function(rs){
                        if(rs.status) {
                            var url = "{{url('order-pay')}}?id="+id;
                            window.location.href = url;
                        }
                    })

                   
                  }, function() {
                    var lat = '-37.81224735868889';
                    var lng = '145.05661176371825';
                    
                  });
                
                } else {
                  
                  var lat = '-37.81224735868889';
                  var lng = '145.05661176371825';
                 
                } 
            })
        </script>



    </body>
</html>